package com.youxin.busfoundation.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

import com.youxin.foundation.data.spark.SparkConfigBean;
import com.youxin.foundation.mq.kafka.KafkaConfigBean;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * Kafka配置加载类
 * @author yingde.cao
 *
 */
@Configuration
@PropertySource("classpath:${spring.profiles.active}/spark.properties")
@ConfigurationProperties(prefix="spark")
public class SparkConfig extends SparkConfigBean{
	
	private static SparkConfig config;
	
	private static Object lockObj=new Object();
	
	/**
	 * 程序启动时加载Spark的配置
	 * @param kafkaConfig
	 */
	public static void initConfig(SparkConfig sparkConfig)
	{
		synchronized (lockObj) {
			if(config==null)
			{
				config=sparkConfig;
			}
		}
	}
	
	/**
	 * 取Spark配置
	 * @return
	 */
	public static SparkConfig getConfig()
	{
		return config;
	}

}
